package com.geek.factory.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.geek.factory.dto.ProductionScheduleDTO;
import com.geek.factory.entity.ProductLine;
import com.geek.factory.entity.ProductionPlan;
import com.geek.factory.entity.ProductionSchedule;
import com.geek.factory.mapper.ProductLineMapper;
import com.geek.factory.mapper.ProductionPlanMapper;
import com.geek.factory.mapper.ProductionScheduleMapper;
import com.geek.factory.service.ProductionScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductionScheduleServiceImpl  extends ServiceImpl<ProductionScheduleMapper, ProductionSchedule> implements ProductionScheduleService {

    @Autowired
    private ProductionScheduleMapper productionScheduleMapper;

    @Autowired
    private ProductionPlanMapper productionPlanMapper;

    @Autowired
    private ProductLineMapper productLineMapper;

    /**
     * 联表查询排班记录（含产线名称和计划编码）
     */
    @Override
    public List<ProductionScheduleDTO> getScheduleWithNames(ProductionScheduleDTO dto) {
        return productionScheduleMapper.selectWithNames(dto);
    }

    /**
     * 联表查询：根据班次查询（含产线名称和计划编码）
     */
    @Override
    public List<ProductionScheduleDTO> getByShift(String shift) {
        return productionScheduleMapper.selectByShiftWithNames(shift);
    }

    /**
     * 根据生产计划ID获取编码
     */
    @Override
    public String getPlanCodeById(Long planId) {
        return productionPlanMapper.getPlanCodeById(planId);
    }

    /**
     * 根据产线ID获取产线名称
     */
    @Override
    public String getProductLineNameById(String productLineId) {
        return productLineMapper.getLineNameById(productLineId);
    }


}